package org.lk.util;

import com.google.gson.Gson;
import org.springframework.stereotype.Component;

/**
 * @author: lk
 * @since:
 * 使用gson的json解析器
 */
@Component
public class JsonUtil {
    private Gson gson = new Gson();

    public String writerAsString(Object data) {
        return gson.toJson(data);
    }

    public <T> T fromJson(String json, Class<T> tClass) {
        return gson.fromJson(json, tClass);
    }
}
